<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf" %>
<script type="text/javascript" src="${ctx}/js/metals/bom/metalsbom_add.js">
</script>

<style type="text/css">
.col-sm-3 {
	width: 15%;
	float: left;
}

.col-sm-9 {
	width: 85%;
	float: left;
}
label[class^="btn btn-default"]{
	margin-top: -4px;
}
</style>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<form id="form" name="form" class="form-horizontal" method="post"
		action="${ctx}/finance/receivables_fine_editEntity.shtml">
		<input type="hidden" class="form-control checkacc" value="${receivablesFormMap.id}"
			name="receivablesFormMap.id" id="id">
		<input type="hidden" class="form-control checkacc" value="${receivablesFormMap.state}"
			name="receivablesFormMap.state" id="id">
		<section class="panel panel-default">
		<div class="panel-body">
		
		
			<div class="form-group">
					<label class="col-sm-3 control-label">送货单号</label>
					<div class="col-sm-9">
						<input type="text" class="form-control checkabh"
							placeholder="送货单号" name="receivablesFormMap.outReceiptNo" id="workcenter_no" value="${receivablesFormMap.outReceiptNo}" readonly/>
						</div>
				</div>
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">合同编号</label>
					<div class="col-sm-9">
						<input type="text" class="form-control checkabh" 
							placeholder="请输入物料名称" name="receivablesFormMap.contract_num" id="workcenter_no" value="${receivablesFormMap.contract_num}" readonly/>
					</div>
				</div>
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">送货日期</label>
					<div class="col-sm-9">
						<input type="text" class="form-control checkName"
							placeholder="请输入规格型号" name="receivablesFormMap.material_time"  value="${receivablesFormMap.material_time}" readonly/>
					</div>
				</div>
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">客户物料编码</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.client_encode"  value="${receivablesFormMap.client_encode }" readonly/>
					</div>
				</div>
				
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">产品名称</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.Name"  value="${receivablesFormMap.Name }" readonly/>
				</div>
			</div>
			
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">单位</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.eunit"  value="${receivablesFormMap.eunit }" readonly/>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">模具号</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.mouldNo"  value="${receivablesFormMap.mouldNo }" readonly/>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">回单数量</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.actualDelivery"  value="${receivablesFormMap.actualDelivery }" readonly/>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">不含税单价</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.priceExcludingTax"  value="${receivablesFormMap.priceExcludingTax }" readonly>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">税率</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.taxRate"  value="${receivablesFormMap.taxRate }" readonly/>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">含税单价</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.unitPriceTaxIncluded"  value="${receivablesFormMap.unitPriceTaxIncluded }" readonly/>
					</div>
				</div>
				
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">金额(含税)</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="请输入定重"
							name="receivablesFormMap.price"  value="${receivablesFormMap.price }" readonly/>
					</div>
				</div>
			
			<!-- 子项 -->
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="panel panel-default">
				<div class="panel-body">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th style="text-align: center;width:135px;">合同编号</th>
								<th style="text-align: center;width:226px;">扣款时间</th>
								<th style="text-align: center;width:135px;">扣款金额</th>
								<th style="text-align: center;width:135px;">扣款原因</th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-primary" onclick="insert_row(this)" value="增加"></th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-danger"  readonly="readonly" value="操作"></th>
							</tr>
						</thead>
						<tbody id="tbl">
							
							<c:forEach var="f" items="${fineFormMaps }" varStatus="status">
									<tr>
									<input type="text" class="form-control page${status.index+1 }" name="aaa" value="${f.id }">
									<td>

										<div class="input-group">
											<input type="hidden" class="form-control" readonly="readonly"
												name="standardId_1"> <input type="text"
												class="form-control" name="item_no_1"
												value="${receivablesFormMap.contract_num}">
										</div>
									</td>
									<td>
										<div class="input-group">
											<input style="width: 100%;" type="datetime-local"
												class="form-control" name="item_time"
												value="${f.chargeTime }" placeholder="">
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control"
												value="${f.price }" name="item_balance_up_1">
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control"
											  value="${f.content }" name="item_balance_down_1" >
										</div>
									</td>
									<td><input type="button" class="btn btn-primary"
										onclick="insert_row(this)" value="增加"></td>
									<td><input type="button" class="btn btn-danger" id="page${status.index+1 }" name="pageNo"
										onclick="deleteRow(this)" value="删除"></td>
								</tr>
								
								</c:forEach>
							
						</tbody>
					</table>
				</div>
			</div>
			</div>
			
			
		</div>
		<footer class="panel-footer text-right bg-light lter">
			<button type="submit" class="btn btn-success btn-s-xs">提交</button>
		</footer> 
		</section>
	</form>
	
	<script type="text/javascript">
		var i = 0
		function insert_row(obj) {
			i++;
			R = tbl.insertRow(tbl.rows.length);
			C = R.insertCell(0);
			C.innerHTML = '<div class="input-group"><input type="text" value="${receivablesFormMap.contract_num}" readonly="readonly"  class="form-control" name="item_no_1" id="item_no_1_"></div>';
			
			C = R.insertCell(1);
			C.innerHTML = '<div class="input-group"><input style="width: 100%;" type="datetime-local" name="item_time" id="item_time" class="form-control"></div>';
			C = R.insertCell(2);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" name="item_balance_up_1" id="item_balance_up_1"></div>'; 
		
			C = R.insertCell(3);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" name="item_balance_down_1" id="item_balance_down_1"></div>';
			C = R.insertCell(4);
			C.innerHTML = '<input type="button" class="btn btn-primary" onclick="insert_row(this)" value="增加">';
			C = R.insertCell(5);
			C.innerHTML = '<input type="button" class="btn btn-danger" onclick ="deleteRow(this)" value ="删除">';
		}
		function deleteRow(obj) {
			
				$("input[name=pageNo]").each(function(){
						layer.confirm('是否删除？', function(index) {
							var oid = $(obj).attr("id");
							var pid=$("."+oid).val();
							//alert($("."+oid).val());
							var url = rootPath + '/finance/receivables_fine_deleteEntity.shtml?pid='+pid;
							var s = CommnUtil.ajax(url, {
								
							}, "json");
							if (s == "success") {
								
								var i = obj.parentNode.parentNode.rowIndex;
								if (i >= 0) {
									tbl.deleteRow(i-1);
								}
								
								layer.msg('删除成功');
								//grid.loadData();
							} else {
								layer.msg('删除失败');
							}
							
						})
					
					
				});
					
		}
	</script>
	
</body>
</html>